package demo3;

public class Text {
    public static void main(String[] args) {
        // 获取第一个实例
        SingletonLazy s1 = SingletonLazy.getInstance();
        System.out.println(s1.getInstance());
        // 获取二个实例
        SingletonLazy s2 = SingletonLazy.getInstance();
        System.out.println(s2.getInstance());
        // 获取第三个实例
        SingletonLazy s3 = SingletonLazy.getInstance();
        System.out.println(s3.getInstance());
    }

    public static void main1(String[] args) {
//        // 获取第一个实例
//        SingletonHungry s1 = new SingletonHungry();
//        System.out.println(s1.getInstance());
//        // 获取第一个实例
//        SingletonHungry s2 = new SingletonHungry();
//        System.out.println(s2.getInstance());
//        // 获取第一个实例
//        SingletonHungry s3 = new SingletonHungry();
//        System.out.println(s3.getInstance());

        // 获取第一个实例
        SingletonHungry s1 = SingletonHungry.getInstance();
        System.out.println(s1.getInstance());
        // 获取二个实例
        SingletonHungry s2 = SingletonHungry.getInstance();
        System.out.println(s2.getInstance());
        // 获取第三个实例
        SingletonHungry s3 = SingletonHungry.getInstance();
        System.out.println(s3.getInstance());

    }
}
